package _01_event_bus._1_0_2_scanning

import akka.actor.ActorRef
import akka.event.{EventBus, ScanningClassification}

/**
  * @author galudisu
  */
class ScanningBusImpl extends EventBus with ScanningClassification {

  override type Event = String
  override type Classifier = Int
  override type Subscriber = ActorRef
  override protected def compareClassifiers(a: Int, b: Int): Int =
    if(a < b) -1 else if(a == b) 0 else 1
  override protected def compareSubscribers(a: ActorRef, b: ActorRef): Int =
    a.compareTo(b)
  override protected def matches(classifier: Int, event: String): Boolean =
    event.length <= classifier
  override protected def publish(event: String, subscriber: ActorRef): Unit =
    subscriber ! event
}
